import 'package:flutter_taotaoshipin/http/request/interact_user_collect_request.dart';
import 'package:flutter_taotaoshipin/http/request/interact_user_collect_rm_request.dart';
import 'package:flutter_taotaoshipin/http/request/interact_user_feedback_list_request.dart';
import 'package:flutter_taotaoshipin/http/request/interact_user_feedback_mul_request.dart';
import 'package:flutter_taotaoshipin/http/request/interact_user_praise_request.dart';
import 'package:flutter_taotaoshipin/http/request/interact_user_praise_rm_request.dart';
import 'package:flutter_taotaoshipin/http/request/interact_user_share_request.dart';
import 'package:flutter_taotaoshipin/http/request/interact_user_sign_in_detail_request.dart';
import 'package:flutter_taotaoshipin/http/request/interact_user_sign_in_request.dart';
import 'package:flutter_taotaoshipin/http/request/interact_user_task_list_request.dart';
import 'package:flutter_taotaoshipin/model/base_entity.dart';
import 'package:flutter_taotaoshipin/model/interact_user_collect_entity.dart';
import 'package:flutter_taotaoshipin/model/interact_user_collect_rm_entity.dart';
import 'package:flutter_taotaoshipin/model/interact_user_feedback_list_entity.dart';
import 'package:flutter_taotaoshipin/model/interact_user_feedback_mul_entity.dart';
import 'package:flutter_taotaoshipin/model/interact_user_praise_entity.dart';
import 'package:flutter_taotaoshipin/model/interact_user_praise_rm_entity.dart';
import 'package:flutter_taotaoshipin/model/interact_user_share_entity.dart';
import 'package:flutter_taotaoshipin/model/interact_user_sign_in_detail_entity.dart';
import 'package:flutter_taotaoshipin/model/interact_user_sign_in_entity.dart';
import 'package:flutter_taotaoshipin/model/interact_user_task_list_entity.dart';
import 'package:hi_net/hi_net.dart';

class InteractDao {
  /// 用户签到
  static Future<BaseEntity<InteractUserSignInEntity>> userSignIn() async {
    var request = InteractUserSignInRequest();
    var result = await HiNet.getInstance().fire(request);
    return BaseEntity<InteractUserSignInEntity>.fromJson(result);
  }

  /// 用户签到详情
  static Future<BaseEntity<InteractUserSignInDetailEntity>>
      userSignInDetail() async {
    var request = InteractUserSignInDetailRequest();
    var result = await HiNet.getInstance().fire(request);
    return BaseEntity<InteractUserSignInDetailEntity>.fromJson(result);
  }

  /// 用户任务列表
  static Future<BaseEntity<List<InteractUserTaskListEntity>>>
      userTaskList() async {
    var request = InteractUserTaskListRequest();
    var result = await HiNet.getInstance().fire(request);
    return BaseEntity<List<InteractUserTaskListEntity>>.fromJson(result);
  }

  /// 用户收藏
  static Future<BaseEntity<InteractUserCollectEntity>> userCollect({
    required int dramaId, // 主剧id
    required int sort, // 当前集数
    required int listId, // 分集id
  }) async {
    var request = InteractUserCollectRequest();
    request.add('drama_id', dramaId);
    request.add('sort', sort);
    request.add('list_id', listId);
    var result = await HiNet.getInstance().fire(request);
    return BaseEntity<InteractUserCollectEntity>.fromJson(result);
  }

  /// 用户取消收藏
  static Future<BaseEntity<InteractUserCollectRmEntity>> userCollectRm({
    required int dramaId, // 主剧id
    required int sort, // 当前集数
    required int listId, // 分集id
  }) async {
    var request = InteractUserCollectRmRequest();
    request.add('drama_id', dramaId);
    request.add('sort', sort);
    request.add('list_id', listId);
    var result = await HiNet.getInstance().fire(request);
    return BaseEntity<InteractUserCollectRmEntity>.fromJson(result);
  }

  /// 用户点赞
  static Future<BaseEntity<InteractUserPraiseEntity>> userPraise({
    required int dramaId, // 主剧id
    required int sort, // 当前集数
    required int listId, // 分集id
  }) async {
    var request = InteractUserPraiseRequest();
    request.add('drama_id', dramaId);
    request.add('sort', sort);
    request.add('list_id', listId);
    var result = await HiNet.getInstance().fire(request);
    return BaseEntity<InteractUserPraiseEntity>.fromJson(result);
  }

  /// 用户取消点赞
  static Future<BaseEntity<InteractUserPraiseRmEntity>> userPraiseRm({
    required int dramaId, // 主剧id
    required int sort, // 当前集数
    required int listId, // 分集id
  }) async {
    var request = InteractUserPraiseRmRequest();
    request.add('drama_id', dramaId);
    request.add('sort', sort);
    request.add('list_id', listId);
    var result = await HiNet.getInstance().fire(request);
    return BaseEntity<InteractUserPraiseRmEntity>.fromJson(result);
  }

  /// 用户分享
  static Future<BaseEntity<InteractUserShareEntity>> userShare({
    required int dramaId, // 主剧id
    required int sort, // 当前集数
    required int listId, // 分集id
  }) async {
    var request = InteractUserShareRequest();
    request.add('drama_id', dramaId);
    request.add('sort', sort);
    request.add('list_id', listId);
    var result = await HiNet.getInstance().fire(request);
    return BaseEntity<InteractUserShareEntity>.fromJson(result);
  }

  /// 用户反馈提列表
  static Future<BaseEntity<List<InteractUserFeedbackListEntity>>>
  userFeedbackList({
    int pageIndex = 1,
    int pageSize = 5,
  }) async {
    var request = InteractUserFeedbackListRequest();
    request.add('page_index', pageIndex);
    request.add('page_size', pageSize);
    var result = await HiNet.getInstance().fire(request);
    return BaseEntity<List<InteractUserFeedbackListEntity>>.fromJson(result);
  }

  /// 用户反馈提交（批量）
  static Future<BaseEntity<InteractUserFeedbackMulEntity>> userFeedbackMul({
    String contacts = '',
    String feedbackTitle = '',
    required String feedbackText,
    List<String> files = const [],
  }) async {
    var request = InteractUserFeedbackMulRequest();
    request.add('contacts', contacts);
    request.add('feedback_title', feedbackTitle);
    request.add('feedback_text', feedbackText);
    request.add('file', files);
    // 请求头
    request.addHeaders('Content-Type', 'multipart/form-data');
    var result = await HiNet.getInstance().fire(request);
    return BaseEntity<InteractUserFeedbackMulEntity>.fromJson(result);
  }

}
